/**
 * 人员资格流程发起
 * 1. 提交流程成功之后，修改
 *  law_card_apply_batch_info 中的 state = 1 待审批
 *  law_card_info 中的
 *  qualification_name 1待审批
 *  qualification_code 1待审批
 */
function main(defaultParams, event) {
    console.log(defaultParams);
    const self = this;

    let applyId = window.APPLYID + '';
    let queryParams = [{
        "name": "pageId",
        "valueContent": "7d8b8cf7-feec-404d-a6e3-665adbd4275b"
    }];

    let jsonParams = {
        documentNo:applyId
    };
    self.$lc_Confirm({
        content: "确定发起人员资格上报流程？",
        type: "info",  // danger info warning
        headerTitle: "提示", //确认框头部标题 提示、警告、告警
        showOkBtn: true, // 是否展示确认按钮
        showCancelBtn: true, // 是否展示取消按钮
        cancelText: "取消", //取消按钮 展示文字
        okText: "确定",  //确认按钮 展示文字
        onOk: () => {
            api.DATA_SOURCE_EXECUTE("ds_api:d4fd4546-c043-4a9e-80d9-5e1cc16fa441", "api", queryParams, [], JSON.stringify(jsonParams)).then((res) => {
                console.log("响应", res);
                if (!res.hasError) {
                    jumpToPage(self, res.result.content || res.result, defaultParams);
                } else {
                    self.$message.error(res.message);
                }
            }).catch(err => {
                self.$message.error(err.message);
            });
        }
    })
}

function jumpToPage(self, result, defaultParams) {
    var element = self;
    var rootPageElement = null;
    result = JSON.parse(result);

    while (element) {
        if (element.getPageInfo && element.goHistory) {
            rootPageElement = element;
            break;
        } else {
            element = element.$parent;
        }
    }
    if (rootPageElement) {
        var data = result.result;
        data.detail = 1;
        data.boxType = 1;
        //data['listId'] = defaultParams['e9bb8f19-df28-48e5-8177-778fb72ed988'];
        //data['listName'] = defaultParams['515d7375-93f1-490f-adab-457648c08c46'];
        //data['listAccount'] = defaultParams['37473ff6-b727-4aa0-904c-da6e0ed5016e'];
        //data['listSponsorAccount'] = defaultParams['2eb012ee-59f7-4a50-9d2d-b60940d872be'];
        //data['listIndicatorName'] = defaultParams['f707371b-c756-4717-afd9-9d4fce38e8e3'];
        //data['reportFlag'] = "上报时赋值标记";
        // 更新页面数据
        rootPageElement.getPageInfo("1932314802592960512");
        // 设置其他参数
        rootPageElement.extraParams_ = data;
    }
    setTimeout(() => {
        console.log(rootPageElement);
    }, 2000)
}
